﻿var star_image_path = Drupal.settings.basePath + 'sites/all/themes/push/images/stars/';
$(document).ready(function(){
	$("#comment-form").before("<div id='node-starrate'>Tổng quan:<div id='star-general'></div>Giao diện:<div id='star-gui'></div>Tính năng:<div id='star-feature'></div>Nội dung:<div id='star-content'></div></div>");
		
	$('#star-general').raty({
		path:star_image_path,
		starOn: 'star-on.png',
		starOff: 'star-off.png',
		onClick: function(score){
			Drupal.settings.note_settings.starRateGeneral = score;
		}
	});
	
	$('#star-gui').raty({
		path:star_image_path,
		starOn: 'star-on.png',
		starOff: 'star-off.png',
		onClick: function(score){
			Drupal.settings.note_settings.starRateGui = score;
		}
	});
	
	$('#star-feature').raty({
		path:star_image_path,
		starOn: 'star-on.png',
		starOff: 'star-off.png',
		onClick: function(score){
			Drupal.settings.note_settings.starRateFeature = score;
		}
	});
	
	$('#star-content').raty({
		path:star_image_path,
		starOn: 'star-on.png',
		starOff: 'star-off.png',
		onClick: function(score){
			Drupal.settings.note_settings.starRateContent = score;
		}
	});
	
	$("#comment-form").submit(function(){
		istart_rate_submit();	
	});
});

function istart_rate_submit(cid)
{
	var starGen = Drupal.settings.note_settings.starRateGeneral;
	var starGui = Drupal.settings.note_settings.starRateGui;
	var starFea = Drupal.settings.note_settings.starRateFeature;
	var starCon = Drupal.settings.note_settings.starRateContent;
	
	var nid = Drupal.settings.note_settings.nid;
	var url = Drupal.settings.basePath + "rate/app_" + nid.toString() + "/" + cid + "/" + starGen + "/" + starGui + "/" + starFea + "/" + starCon;

	$.ajax({
			type: "GET",
			url: url
		});		
}